<?php
class Index_Controller {
	function getUserName($loginid) {
		require APP_DIR.'/host_config.php';
		require_once Models_DIR.'MySQL.php';
		$mysql = new MySQL();
		$link = $mysql->connect($mysql_host, $mysql_user, $mysql_password, $mysql_db);
		$sql = "SELECT account FROM LoginUser WHERE loginid = '$loginid'";
		$user = $mysql->query_array($sql, $link);
		return $user['account'];
	}
	function getShopName($loginid) {
		require_once (Models_DIR.'index_model.php');
		$index_model = new Index_Model();
		return $index_model->getShopName($loginid);
	}
	function getMaxNumber($loginid) {
		require APP_DIR.'/host_config.php';
		require_once Models_DIR.'MySQL.php';
		$mysql = new MySQL();
		$link = $mysql->connect($mysql_host, $mysql_user, $mysql_password, $mysql_db);
		$sql = "select Shops.maxofnumber from LoginUser JOIN Shops ON LoginUser.shopname = Shops.fullname WHERE LoginUser.loginid = '$loginid'";
		$row = $mysql->query_row($sql, $link);
		return $row[0];
	}
	function getCurrentNumber($loginid) {
		require APP_DIR.'/host_config.php';
		require_once Models_DIR.'MySQL.php';
		$mysql = new MySQL();
		$link = $mysql->connect($mysql_host, $mysql_user, $mysql_password, $mysql_db);
		$sql = "select Shops.currentnumber from LoginUser JOIN Shops ON LoginUser.shopname = Shops.fullname WHERE LoginUser.loginid = '$loginid'";
		$row = $mysql->query_row($sql, $link);
		return $row[0];
	}
	function getShopStatus($shopid) {
		require APP_DIR.'/host_config.php';
		require_once Models_DIR.'MySQL.php';
		$mysql = new MySQL();
		$link = $mysql->connect($mysql_host, $mysql_user, $mysql_password, $mysql_db);
		$sql = "select open from Shops WHERE shopid = '$shopid'";
		$row = $mysql->query_row($sql, $link);
		return $row[0];
	}
}
?>